<?php
namespace app\common;
use think\Controller;
class Base extends Controller {
	public function _initialize(){
		$this->loadConfig();
	}

	public function jerror($mess='failed',$id=1,$data=null){
		return json(['state'=>$id,'mess'=>$mess,'data'=>$data]);
	}
	
	public function jsuccess($data=null,$mess='success'){
		return json(['state'=>0,'mess'=>$mess,'data'=>$data]);
	}

	protected function loadConfig(){
		$config=cache('application_system_config');
		if(!$config){
			$config=[];
			$configInfo=db('config')->field('conf_name,conf_value')->select();
			foreach($configInfo as $key=>$value){
				$config[$value['conf_name']]=$value['conf_value'];
			}
			cache('application_system_config',$config);
		}
		config($config);
	}
}
?>
